
Blockly.defineBlocksWithJsonArray([{
    "type": "time_block",
    "message0": "%1时 %2分 %3秒",
    "args0": [
    {
        "type": "input_value",
        "name": "HOUR",
        "min": 0,
        "max": 23,
        "value": 0,
        "check": "Number"
    },
    {
        "type": "input_value",
        "name": "MINITES",
        "min": 0,
        "max": 59,
        "value": 1,
        "check": "Number"
    },
    {
        "type": "input_value",
        "name": "SECONDS",
        "min": 0,
        "max": 59,
        "value": 1,
        "check": "Number"
    }
    ],
    "inputsInline": true,
    "output": "Number",
    "colour": "%{BKY_LOOPS_HUE}"
  }]);
  



  
  Blockly.Lua['time_block'] = function(block) {
  
    var hour =   Blockly.Lua.valueToCode(block, 'HOUR', Blockly.Lua.ORDER_NONE) || '0'; 
    var minites = Blockly.Lua.valueToCode(block, 'MINITES', Blockly.Lua.ORDER_NONE) || '0';
    var seconds =  Blockly.Lua.valueToCode(block, 'SECONDS', Blockly.Lua.ORDER_NONE) || '0';
    
    hour = hour*3600;
    minites = minites*60;
    seconds = seconds*1;
    var code = hour + minites + seconds;
    var order = Blockly.Lua.ORDER_NONE;  // ORDER_xxx 是指优先级

    return [code,order] ; // 很多时候要return一个包含代码和优先级的数组 
  };
  
  